-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
taprpc: decimal display requires JSON meta #983
Conversation
In this commit, we require an asset request with a custom decimal display to have a non-empty meta field. Without this check, the asset would be created with no metadata and therefore have the default decimal display value of 0.
// If a custom decimal display is set, the meta type must also be set to | ||
// JSON. | ||
if req.Asset.DecimalDisplay != 0 && req.Asset.AssetMeta == nil { | ||
return nil, fmt.Errorf("decimal display requires JSON asset " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to instead bootstrap the meta json with just the decimal display field? otherwise a user will have to provide an empty json {}
for this to work, which might not be intuitive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with setting to an empty meta json if the meta field nil in the request but a decimal display is given.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AssetMeta
field here is both Data
and Type
. So we require Type
to be set t JSON for decimal display to get set as the only JSON field if the metadata data field was empty.
Was implemented in #979 , seen here:
Line 533 in 311231d
if metaType == proof.MetaJson && req.Asset.DecimalDisplay != 0 { |
This check is added before that bootstrapping to enforce that the user at least set the correct metadata type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do this: 5fa519d#r1658411119
And then should be good to go.
// If a custom decimal display is set, the meta type must also be set to | ||
// JSON. | ||
if req.Asset.DecimalDisplay != 0 && req.Asset.AssetMeta == nil { | ||
return nil, fmt.Errorf("decimal display requires JSON asset " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with setting to an empty meta json if the meta field nil in the request but a decimal display is given.
Follow-on to #979 .
For minting via RPC, there was a missing check to prevent the decimal display value from being dropped before reaching the minter.